package com.yunheone.view.Teach;

import com.yunheone.control.Teachcon;
import com.yunheone.mode.TeacherUser;

import java.util.Scanner;

/**
 * Created by Administrator on 2017/8/9 0009.
 */
public class TeacherAdd {

    public static TeacherUser teacherAdd(){
        System.out.println ("*********学员信息管理系统—添加讲师*********");
        Scanner input=new Scanner ( System.in );
        System.out.println ("请输入要添加的用户信息：");
        System.out.print ("请输入用户编号:");
        String id=input.next ();
        System.out.print("请输入用户名:");
        String Name=input.next ();
        System.out.print("请输入性别(男/女):");
        String sex=input.next ();
        System.out.print("请输入年龄:");
        String age=input.next ();
        try{
            if (Teachcon.getTeacheruse ().containsKey ( id )){
                throw new Exception ("编号已存在，请重新输入");
            } else if (!sex.equals ( "男" )&&!sex.equals ( "女" )){
                throw new Exception ( "性别输入有误，请重新输入" );
            }
            return new TeacherUser ( id,Name,sex,age );
        }catch (Exception e){
            String message = e.getMessage ();
            System.out.println (message!=null?message:"输入不合法");
            return teacherAdd ();
        }
    }

}
